package com.action.basic;

import java.util.List;

import com.action.common.WEB;
import com.opensymphony.xwork2.ActionSupport;
import com.pojo.basic.CurId;
import com.service.basic.ICurIdService;
import com.util.ActionLog;
import com.util.GTC;

public class CurIdAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private ICurIdService curIdService;
	private List<CurId> curids;
	private String datas;
	
	//setter getter
	
	public void setCurIdService(ICurIdService curIdService) {
		this.curIdService = curIdService;
	}
	
	public String getDatas() {
		return datas;
	}

	public void setDatas(String datas) {
		this.datas = datas;
	}

	public List<CurId> getCurids() {
		return curids;
	}

	public void setCurids(List<CurId> curids) {
		this.curids = curids;
	}
	
	//action method

	public String initCurIdData(){
		this.curIdFormatExtArray(curIdService.findAllCurId());
		return SUCCESS;
	}
	
	public void curIdFormatExtArray(List<CurId> lists){
		ActionLog.info(this.getClass(),"["+WEB.getClassName(this.getClass())+"]:【對象轉換為JS字符串形式顯示在頁面】");
		StringBuffer sb = new StringBuffer();
		sb.append("[");
		for(CurId curid : lists){
			sb.append("['"+curid.getId().getCurId()+"','"+GTC.nullEmpty(curid.getName())+"','"+GTC.nullEmpty(curid.getId().getIjDd())+"','"+GTC.nullEmpty(curid.getExcRto())+"','"+GTC.nullEmpty(curid.getExcRtoI())+"','"+GTC.nullEmpty(curid.getExcRtoO())+"'],");
		}
		this.setDatas(sb.toString().substring(0, sb.toString().length()-1)+"]");
	}
}
